# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@mirantis.com>
# Contributor: Thomas Bächler <thomas@archlinux.org>

pkgname=libpcap
pkgver=1.10.4
pkgrel=1
pkgdesc='A system-independent interface for user-level packet capture'
arch=(x86_64)
url='https://www.tcpdump.org/'
license=(BSD)
depends=(
  glibc
  libnl
  sh
)
makedepends=(
  bluez-libs
  dbus
)
provides=(libpcap.so)
source=(https://www.tcpdump.org/release/$pkgname-$pkgver.tar.gz{,.sig})
sha512sums=('1f6d6ddd07dae7c557054cb246437ecdaf39d579592a5a6bdf1144eea6cb5a779ac4ca647cfed11ec1b0bb18efc63b845444e497070bacefaaed19a5787ae5e1'
            'SKIP')
b2sums=('05a7eafc1e1817f7844008db89d8fb10cd2525c22f7ee6c9e3d582b14229412f38ccced5e9d80a96dd459ef9eab12eccb5c1dd4978ddc9f66267469212005e4c'
        'SKIP')
validpgpkeys=('1F166A5742ABB9E0249A8D30E089DEF1D9C15D0D') # The Tcpdump Group

prepare() {
  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  local configure_options=(
    --prefix=/usr
    --enable-ipv6
    --enable-bluetooth
    --enable-usb
    --with-libnl
  )

  cd $pkgname-$pkgver
  ./configure "${configure_options[@]}"
  make
}

package() {
  depends+=(libdbus-1.so)

  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {CHANGES,{CONTRIBUTING,README}.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
